﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using famails.iface;
using famails.dao;
using famails.common;
using famails.dto;

namespace famails.bus
{
    /// <summary>
    /// Summary description for CustomerBUS
    /// </summary>
    public class ClientBUS : IClient
    {
        ClientDAO ctDao = null;
        public ClientBUS()
        {
            ctDao = new ClientDAO();
        }

        public bool Customer_Lock_Unlock(int Id, Common.clientStatus status)
        {
            return ctDao.Customer_Lock_Unlock(Id, status);
        }

        public DataTable Search(string name, string email, string phone, bool isCheckExpire, string from, string to)
        {
            return ctDao.Search(name, email, phone, isCheckExpire, from, to);
        }

        public DataTable GetByID(int Id)
        {
            return ctDao.GetByID(Id);
        }
        public DataTable GetByClientID(int Id)
        {
            return ctDao.GetByClientID(Id);
        }
        public DataTable getallclient(int clinetId)
        {
            return ctDao.getallclient(clinetId);
        }

        public DataTable GetByEmail(string Email)
        {
            return ctDao.GetByEmail(Email);
        }
        public void UpdateInfomation(ClientDTO dto)
        {
            ctDao.UpdateInfomation(dto);
        }
        public void UpdateExtendLicense(string clientid, DateTime activeday, DateTime expireday)
        {
            ctDao.UpdateExtendLicense(clientid, activeday, expireday);
        }
        public void UpdateRegiterId(int clientId, string activeDay, string expireDay, int lastRegisterId, int registerId)
        {
            ctDao.UpdateRegiterId(clientId, activeDay, expireDay, lastRegisterId, registerId);
        }

        internal bool Customer_Active(int id)
        {
            return ctDao.Customer_Active(id);
        }
        /// <summary>
        /// Chỉ xóa được khi tài khoản chưa phát sinh gửi mail
        /// </summary>
        /// <param name="clinetId"></param>
        /// <returns></returns>
        internal bool Delete(int clinetId)
        {
            return ctDao.Delete(clinetId);
        }

        internal DataTable LoadThongTinDangKy(int id)
        {
            return ctDao.LoadThongTinDangKy(id);
        }

        public void UpdatePayment(string receiverId)
        {
            ctDao.UpdatePayment(receiverId);
        }

        public bool CancelTransaction(string registerid)
        {
            return ctDao.CancelTransaction(registerid);
        }
    }
}